﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Index.Master" Inherits="System.Web.Mvc.ViewPage<Langben.DAL.ts_goods>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    物品库存帐报表
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<input type="hidden" id="hiddenSearch" /> 
    <div id="divQuery"  title="查询列表" class="easyui-dialog" closed="true" modal="false"
        iconcls="icon-search" style=" width:500px;">
          <div class="input">
           <table width="90%">
           <tr style="line-height:30px">
           <td width="100px">日期</td>
           <td width="170px"><input type='text' id='tbStart' style="width:170px" class="easyui-datebox"/></td>
           <td width="10px" align="left">到</td>
           <td width="170px"><input type='text' id='tbEnd' style="width:170px" class="easyui-datebox"/></td>
           </tr> 
           <tr><td>仓库</td><td colspan="3"> <%=Html.DropDownListFor(model => model.c_base, Models.SysFieldModels.GetBaseInf(), "请选择")%></td></tr>
           <tr><td>物品编码</td><td colspan="3"><input type="text" id="tbc_code" /><input type="button" id="btSearch" value="查找" onclick="showDisTypeOnly('c_code','../../ts_goods');" />
           </td></tr>
           </table> 
            </div>   
            </div>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="HeadContent" runat="server">
 <script src="../../Lodop/LodopFuncs.js" type="text/javascript"></script>
     <object id="LODOP_OB" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width=0 height=0> 
	    <embed id="LODOP_EM" type="application/x-print-lodop" width=0 height=0 pluginspage="install_lodop32.exe"></embed>
    </object> 
     

   <script type="text/javascript" language="javascript">

       var LODOP; //声明为全局变量 
        
       function prn1_preview(data) {
           LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'));
           LODOP.PRINT_INIT("打印控件功能演示_Lodop功能_打印表格");

           //报表标题 
           LODOP.ADD_PRINT_HTM(30, 300, 330, 300, "<font color ='black' size ='4'>结账单查询</font>");
           //报表内容打印。 
           LODOP.ADD_PRINT_HTM(100, "5%", "90%", 314, data);
           LODOP.PREVIEW();
       };

       function prn1_print(data) {
           LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'));
           LODOP.PRINT_INIT("打印控件功能演示_Lodop功能_打印表格");

           //报表标题 
           LODOP.ADD_PRINT_HTM(30, 300, 330, 300, "<font color ='black' size ='4'>结账单查询</font>");
           //报表内容打印。 
           LODOP.ADD_PRINT_HTM(100, "5%", "90%", 314, data);
           LODOP.PRINT();
       };
  </script>

   <script type="text/javascript" language="javascript">
       $(function () {

           $('#flexigridData').datagrid({
               title: '物品库存帐报表', //列表的标题
               iconCls: 'icon-site',
               width: 'auto',
               height: 'auto',
               nowrap: false,
               striped: true,
               collapsible: true,
               url: '../../ts_goods/GetWPKCZBBData', //获取数据的url
               sortName: 'Id',
               sortOrder: 'desc',
               idField: 'Id',

               toolbar: [
                 {
                     text: '查询',
                     iconCls: 'icon-search',
                     handler: function () {
                         flexiQuery();
                     }
                 },
                  {
                      text: '打印预览',
                      iconCls: 'icon-search',
                      name: 'button_print',
                      handler: function () {
                          $.post("../ts_goods/PrintWPKCZBB", { search: $("#hiddenSearch").val() }, function (res) {

                              prn1_preview(res.data);

                          });

                      }
                  },
                  {
                      text: '打印',
                      iconCls: 'icon-search',
                      name: 'button_print',
                      handler: function () {
                          $.post("../ts_goods/PrintWPKCZBB", { search: $("#hiddenSearch").val() }, function (res) {
                              prn1_preview(res.data);

                          });
                      }
                  }],
               columns: [[
                      { field: 'c_class', title: '类型', width: 100 }
					, { field: 'dt_dt', title: '日期', width: 100 }
                    , { field: 'c_base', title: '仓库', width: 90 }
                    , { field: 'RKSL', title: '进库数量', width: 90 }
                    , { field: 'RKJE', title: '进库金额', width: 60 }
                    , { field: 'CKSL', title: '出库数量', width: 90 }
                    , { field: 'CKJE', title: '出库金额', width: 60 }
                    , { field: 'QMSL', title: '结存数量', width: 90 }
                    , { field: 'QMJE', title: '结存金额', width: 60 } 
                    , { field: 'c_comment', title: '备注', width: 90 } 
                ]],
               pagination: true,
               rownumbers: true

           });

           var parent = window.dialogArguments; //获取父页面
           if (parent == "undefined" || parent == null) {
               //    不是在iframe中打开的
           } else {
               //隐藏所有的按钮和分隔符
               $(".l-btn.l-btn-plain").hide();
               $(".datagrid-btn-separator").hide();
               //添加选择按钮
               $('#flexigridData').datagrid("addToolbarItem", [{ "text": "选择", "iconCls": "icon-ok", handler: function () { flexiSelect(); } }]);
           }
       });


       function showDisTypeOnly(me, url) { //弹出窗体 ,单选 
         
           var reValue = window.showModalDialog(url, window, "dialogHeight:500px; dialogWidth:987px;  status:off; scroll:auto");

           if (reValue == null || reValue == "undefined" || reValue == "") {
               return; //如果返回值为空，就返回
           }
           var index = reValue.split("^"); //分割符 ^ 的位置
           if (index[0] == null || index[0] == "undefined" || index[0].length < 1) {
               return;
           }
 
           var hid = index[0].split('&'); //为隐藏控件赋值
           var view = index[1].split('&'); //显示值
           var content = ""; //需要添加到check中的内容
 
           if (hid != null && hid.length == 2) {
               var i = 0; 
               if (hid[i] != "undefined" && hid[i] != "" && view[i + 1] != "undefined" && view[i + 1] != "") {
                  
                   var c = document.getElementById("tb" + me); 
                   c.value = view[i + 1]; 
                   return;
               } 
           }
           alert("请只选择一条数据。");
           return;
       }


       //“查询”按钮，弹出查询框
       function flexiQuery() {
           $('#divQuery').dialog({
               buttons: [{
                   text: '查询',
                   iconCls: 'icon-ok',
                   handler: function () {
                       //将查询条件按照分隔符拼接成字符串
                       var search = "";
                       search += "tbStart" + "&" + $('#tbStart').datebox('getValue') + "^";
                       search += "tbEnd" + "&" + $('#tbEnd').datebox('getValue') + "^";
                       search += "c_base" + "&" + $('#c_base').val() + "^";
                       search += "tbc_code" + "&" + $('#tbc_code').val() + "^";
                       //                       $('#divQuery').find(":text,:selected,select,textarea,:hidden,:checked,:password").each(function () {
                       //                           search = search + this.id + "&" + this.value + "^";
                       //                       });
                       //执行查询                        
                       $('#flexigridData').datagrid('reload', { search: search });
                       $('#hiddenSearch').val(search);
                   }
               },
                     {
                         text: '取消',
                         iconCls: 'icon-cancel',
                         handler: function () {
                             $('#divQuery').dialog("close");
                         }
                     }]
           });
           $('#divQuery').dialog("open");
           //将查询条件按照分隔符拼接成字符串           

       };
        

       //“选择”按钮，在其他（与此页面有关联）的页面中，此页面以弹出框的形式出现，选择页面中的数据
       function flexiSelect() {

           var rows = $('#flexigridData').datagrid('getSelections');
           if (rows.length == 0) {
               $.messager.alert('操作提示', '请选择数据!', 'warning');
               return false;
           }

           var arr = [];
           for (var i = 0; i < rows.length; i++) {
               arr.push(rows[i].Id);
           }
           arr.push("^");
           for (var i = 0; i < rows.length; i++) {
               arr.push(rows[i].cardclassID);
           }
           //主键列和显示列之间用 ^ 分割   每一项用 , 分割
           if (arr.length > 0) {//一条数据和多于一条
               returnParent(arr.join("&")); //每一项用 & 分割
           }
       }
            
    </script>

</asp:Content>
